package com.zy.explore.demo.domain.entity;

import com.zy.explore.demo.domain.repository.SysUserRepository;
import com.zy.explore.base.jpa.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
import java.util.Date;
import java.io.Serializable;

/**
 * 系统用户表(表sys_user)ORM实体对象
 *
 * @author ZY
 * @date 2021-05-05 23:07:48
 */
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@Builder(builderClassName = "Builder")
@NoArgsConstructor
@AllArgsConstructor
@DynamicUpdate
@DynamicInsert
@Table(name = "sys_user")
public class SysUser extends BaseEntity<SysUserRepository, SysUser, Integer> {

    private static final long serialVersionUID = -84224770607482197L;

    /**
     * 系统用户ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "JDBC")
    @Column(name = "id", insertable = false, updatable = false, nullable = false, columnDefinition = "bigint(20) COMMENT '表主键自增ID'")
    private Integer id;

    /**
     * 姓名
     */
    private String name;

    /**
     * 手机号码
     */
    private String phone;

    /**
     * 住宅电话
     */
    private String telephone;

    /**
     * 联系地址
     */
    private String address;

    /**
     * 是否可用：0.禁用 1.可用
     */
    private Integer enabled;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 用户头像
     */
    private String avatar;

    /**
     * 备注
     */
    private String remark;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;


    private static SysUserRepository repository() {
        return SysUser.Holder.REPO;
    }

    private static final class Holder {
        private static final SysUserRepository REPO = getRepository(SysUserRepository.class, SysUser.class);
    }

}